package org.mall.modules.member.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mall.modules.member.entity.MemberShopCollectionDO;
import org.mall.modules.pojo.member.MemberShopCollectionBO;

/***
 *@author yinxucun
 *@date 2019-12-28 13:54 
 */
@Mapper
public interface MemberShopCollectionMapper extends BaseMapper<MemberShopCollectionDO> {
    @Select("select * from member_shop_collection where user_id = #{userId}  ")
    IPage<MemberShopCollectionBO> getListByUserId(Page page, @Param("userId") String userId);

    @Delete("delete from member_shop_collection   where user_id = #{userId} and shop_id = #{shopId}")
    Boolean removeUserFavorite(@Param("userId") String userId, @Param("shopId") String shopId);

    @Select("select count(1)  from member_shop_collection  where user_id = #{userId} and shop_id  =  #{shopId}  limit 1")
    Integer hasFavorite(@Param("userId") String userId, @Param("shopId") String shopId);
}
